import { Certificate } from "./utils/Certificate";
import { util } from "utils";
import { createOrderAction } from "./action/createOrder";
import type { CloudObject } from "./types";
let _localCertificate: Certificate | undefined = undefined;

const wxPay: CloudObject = {
    _before: function () {
        // 通用预处理器
        // 创建 证书
        if (util.nilValue(_localCertificate)) {
            _localCertificate = new Certificate();
        }
    },
    // 创建订单
    async createOrder(params: { [k: string]: any }) {
        let httpInfo = this.getHttpInfo() || {};
        return await createOrderAction(params, httpInfo, _localCertificate);
    },
};
export default wxPay;
